
package com.x52im.rbchat.logic.contact.viewholder.head;

import android.view.View;
import android.widget.TextView;

import com.eva.android.ToolKits;
import com.x52im.rbchat.logic.contact.FriendListAdapter;
import com.x52im.rbchat.logic.contact.model.FriendRequestHeaderItemValue;
import com.x52im.rbchat.R;

import androidx.fragment.app.Fragment;

public class FriendRequestItemViewHolder extends HeaderItemViewHolder<FriendRequestHeaderItemValue> {

    private TextView unreadRequestCountTextView;
    private FriendRequestHeaderItemValue value;

    public FriendRequestItemViewHolder(Fragment fragment, FriendListAdapter adapter, View itemView) {
        super(fragment, adapter, itemView);
        unreadRequestCountTextView = itemView.findViewById(R.id.unreadFriendRequestCountTextView);
    }

    @Override
    public void onBind(FriendRequestHeaderItemValue value) {
        this.value = value;
//        int count = ChatManager.Instance().getUnreadFriendRequestStatus();
        int count = value.getUnreadRequestCount();
        // 角标数字显示文本处理
        String mBadgeText = ToolKits.getBadgeViewString(count);
        unreadRequestCountTextView.setText(mBadgeText);
        if (count > 0) {
            unreadRequestCountTextView.setVisibility(View.VISIBLE);
        } else {
            unreadRequestCountTextView.setVisibility(View.GONE);
        }
    }
}